<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css">
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
<link rel="Start" href="index.html">
<link rel="next" href="Xml.html">
<link rel="Up" href="index.html">
<link title="Index of types" rel=Appendix href="index_types.html">
<link title="Index of exceptions" rel=Appendix href="index_exceptions.html">
<link title="Index of values" rel=Appendix href="index_values.html">
<link title="Index of modules" rel=Appendix href="index_modules.html">
<link title="Dtd" rel="Chapter" href="Dtd.html">
<link title="Xml" rel="Chapter" href="Xml.html">
<link title="XmlParser" rel="Chapter" href="XmlParser.html"><link title="The DTD Types" rel="Section" href="#6_TheDTDTypes">
<link title="The DTD Functions" rel="Section" href="#6_TheDTDFunctions">
<link title="The DTD Exceptions" rel="Section" href="#6_TheDTDExceptions">
<title>Dtd</title>
</head>
<body>
<div class="navbar">&nbsp;<a href="index.html">Up</a>
&nbsp;<a href="Xml.html">Next</a>
</div>
<center><h1>Module <a href="type_Dtd.html">Dtd</a></h1></center>
<br>
<pre><span class="keyword">module</span> Dtd: <code class="code">sig</code> <a href="Dtd.html">..</a> <code class="code">end</code></pre>Xml Light DTD
<p>

	This module provide several functions to create, check, and use DTD
	to prove Xml documents : <ul>
<li>using the DTD types, you can directly create your own DTD structure</li>
<li>the <a href="Dtd.html#VALcheck"><code class="code">Dtd.check</code></a> function can then be used to check that all DTD
		states have been declared, that no attributes are declared twice,
		and so on.</li>
<li>the <a href="Dtd.html#VALprove"><code class="code">Dtd.prove</code></a> function can be used to check an <a href="Xml.html"><code class="code">Xml</code></a> data
		structure with a checked DTD. The function will return the
		expanded Xml document or raise an exception if the DTD proving
		fails.</li>
</ul>

<p>

	<i>Note about ENTITIES:</i>
<p>

	While parsing Xml, PCDATA is always parsed and
	the Xml entities &amp;amp; &amp;gt; &amp;lt; &amp;apos; &amp;quot; are replaced by their
	corresponding ASCII characters. For Xml attributes, theses can be
	put between either double or simple quotes, and the backslash character
	can be used to escape inner quotes. There is no support for CDATA Xml
	nodes or PCDATA attributes declarations in DTD, and no support for
	user-defined entities using the ENTITY DTD element.<br>
<hr width="100%">
<br>
<a name="6_TheDTDTypes"></a>
<h6>The DTD Types</h6><br>
<br><code><span class="keyword">type</span> <a name="TYPEdtd_child"></a><code class="type"></code>dtd_child = </code><table class="typetable">
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">DTDTag</span> <span class="keyword">of</span> <code class="type">string</code></code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">DTDPCData</span></code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">DTDOptional</span> <span class="keyword">of</span> <code class="type"><a href="Dtd.html#TYPEdtd_child">dtd_child</a></code></code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">DTDZeroOrMore</span> <span class="keyword">of</span> <code class="type"><a href="Dtd.html#TYPEdtd_child">dtd_child</a></code></code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">DTDOneOrMore</span> <span class="keyword">of</span> <code class="type"><a href="Dtd.html#TYPEdtd_child">dtd_child</a></code></code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">DTDChoice</span> <span class="keyword">of</span> <code class="type"><a href="Dtd.html#TYPEdtd_child">dtd_child</a> list</code></code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">DTDChildren</span> <span class="keyword">of</span> <code class="type"><a href="Dtd.html#TYPEdtd_child">dtd_child</a> list</code></code></td>

</tr></table>


<br><code><span class="keyword">type</span> <a name="TYPEdtd_element_type"></a><code class="type"></code>dtd_element_type = </code><table class="typetable">
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">DTDEmpty</span></code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">DTDAny</span></code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">DTDChild</span> <span class="keyword">of</span> <code class="type"><a href="Dtd.html#TYPEdtd_child">dtd_child</a></code></code></td>

</tr></table>


<br><code><span class="keyword">type</span> <a name="TYPEdtd_attr_default"></a><code class="type"></code>dtd_attr_default = </code><table class="typetable">
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">DTDDefault</span> <span class="keyword">of</span> <code class="type">string</code></code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">DTDRequired</span></code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">DTDImplied</span></code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">DTDFixed</span> <span class="keyword">of</span> <code class="type">string</code></code></td>

</tr></table>


<br><code><span class="keyword">type</span> <a name="TYPEdtd_attr_type"></a><code class="type"></code>dtd_attr_type = </code><table class="typetable">
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">DTDCData</span></code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">DTDNMToken</span></code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">DTDEnum</span> <span class="keyword">of</span> <code class="type">string list</code></code></td>

</tr></table>


<br><code><span class="keyword">type</span> <a name="TYPEdtd_item"></a><code class="type"></code>dtd_item = </code><table class="typetable">
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">DTDAttribute</span> <span class="keyword">of</span> <code class="type">string * string * <a href="Dtd.html#TYPEdtd_attr_type">dtd_attr_type</a> * <a href="Dtd.html#TYPEdtd_attr_default">dtd_attr_default</a></code></code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">DTDElement</span> <span class="keyword">of</span> <code class="type">string * <a href="Dtd.html#TYPEdtd_element_type">dtd_element_type</a></code></code></td>

</tr></table>


<pre><span class="keyword">type</span> <a name="TYPEdtd"></a><code class="type"></code>dtd = <code class="type"><a href="Dtd.html#TYPEdtd_item">dtd_item</a> list</code> </pre>

<pre><span class="keyword">type</span> <a name="TYPEchecked"></a><code class="type"></code>checked </pre>

<br>
<a name="6_TheDTDFunctions"></a>
<h6>The DTD Functions</h6><br>
<pre><span class="keyword">val</span> <a name="VALparse_file"></a>parse_file : <code class="type">string -> <a href="Dtd.html#TYPEdtd">dtd</a></code></pre><div class="info">
Parse the named file into a Dtd data structure. Raise
	<a href="Xml.html#EXCEPTIONFile_not_found"><code class="code">Xml.File_not_found</code></a> if an error occured while opening the file. 
	Raise <a href="Dtd.html#EXCEPTIONParse_error"><code class="code">Dtd.Parse_error</code></a> if parsing failed.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALparse_in"></a>parse_in : <code class="type">Pervasives.in_channel -> <a href="Dtd.html#TYPEdtd">dtd</a></code></pre><div class="info">
Read the content of the in_channel and parse it into a Dtd data
 structure. Raise <a href="Dtd.html#EXCEPTIONParse_error"><code class="code">Dtd.Parse_error</code></a> if parsing failed.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALparse_string"></a>parse_string : <code class="type">string -> <a href="Dtd.html#TYPEdtd">dtd</a></code></pre><div class="info">
Parse the string containing a Dtd document into a Dtd data
 structure. Raise <a href="Dtd.html#EXCEPTIONParse_error"><code class="code">Dtd.Parse_error</code></a> if parsing failed.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALcheck"></a>check : <code class="type"><a href="Dtd.html#TYPEdtd">dtd</a> -> <a href="Dtd.html#TYPEchecked">checked</a></code></pre><div class="info">
Check the Dtd data structure declaration and return a checked
 DTD. Raise <a href="Dtd.html#EXCEPTIONCheck_error"><code class="code">Dtd.Check_error</code></a> if the DTD checking failed.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALprove"></a>prove : <code class="type"><a href="Dtd.html#TYPEchecked">checked</a> -> string -> <a href="Xml.html#TYPExml">Xml.xml</a> -> <a href="Xml.html#TYPExml">Xml.xml</a></code></pre><div class="info">
Prove an Xml document using a checked DTD and an entry point.
 The entry point is the first excepted tag of the Xml document,
 the returned Xml document has the same structure has the original
 one, excepted that non declared optional attributes have been set
 to their default value specified in the DTD.
 Raise <a href="Dtd.html#EXCEPTIONCheck_error"><code class="code">Dtd.Check_error</code></a> <code class="code">ElementNotDeclared</code> if the entry point
 is not found, raise <a href="Dtd.html#EXCEPTIONProve_error"><code class="code">Dtd.Prove_error</code></a> if the Xml document failed
 to be proved with the DTD.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALto_string"></a>to_string : <code class="type"><a href="Dtd.html#TYPEdtd_item">dtd_item</a> -> string</code></pre><div class="info">
Print a DTD element into a string. You can easily get a DTD
 document from a DTD data structure using for example
 <code class="code">String.concat "\n" (List.map Dtd.to_string) my_dtd</code><br>
</div>
<br>
<a name="6_TheDTDExceptions"></a>
<h6>The DTD Exceptions</h6><br>
<br>
There is three types of DTD excecptions : <ul>
<li><a href="Dtd.html#EXCEPTIONParse_error"><code class="code">Dtd.Parse_error</code></a> is raised when an error occured while
	parsing a DTD document into a DTD data structure.</li>
<li><a href="Dtd.html#EXCEPTIONCheck_error"><code class="code">Dtd.Check_error</code></a> is raised when an error occured while
	checking a DTD data structure for completeness, or when the
	prove entry point is not found when calling <a href="Dtd.html#VALprove"><code class="code">Dtd.prove</code></a>.</li>
<li><a href="Dtd.html#EXCEPTIONProve_error"><code class="code">Dtd.Prove_error</code></a> is raised when an error occured while
	proving an Xml document.</li>
</ul>

<p>

	Several string conversion functions are provided to enable you
	to report errors to the user.<br>
<br><code><span class="keyword">type</span> <a name="TYPEparse_error_msg"></a><code class="type"></code>parse_error_msg = </code><table class="typetable">
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">InvalidDTDDecl</span></code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">InvalidDTDElement</span></code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">InvalidDTDAttribute</span></code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">InvalidDTDTag</span></code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">DTDItemExpected</span></code></td>

</tr></table>


<br><code><span class="keyword">type</span> <a name="TYPEcheck_error"></a><code class="type"></code>check_error = </code><table class="typetable">
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">ElementDefinedTwice</span> <span class="keyword">of</span> <code class="type">string</code></code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">AttributeDefinedTwice</span> <span class="keyword">of</span> <code class="type">string * string</code></code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">ElementEmptyContructor</span> <span class="keyword">of</span> <code class="type">string</code></code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">ElementReferenced</span> <span class="keyword">of</span> <code class="type">string * string</code></code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">ElementNotDeclared</span> <span class="keyword">of</span> <code class="type">string</code></code></td>

</tr></table>


<br><code><span class="keyword">type</span> <a name="TYPEprove_error"></a><code class="type"></code>prove_error = </code><table class="typetable">
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">UnexpectedPCData</span></code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">UnexpectedTag</span> <span class="keyword">of</span> <code class="type">string</code></code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">UnexpectedAttribute</span> <span class="keyword">of</span> <code class="type">string</code></code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">InvalidAttributeValue</span> <span class="keyword">of</span> <code class="type">string</code></code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">RequiredAttribute</span> <span class="keyword">of</span> <code class="type">string</code></code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">ChildExpected</span> <span class="keyword">of</span> <code class="type">string</code></code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">EmptyExpected</span></code></td>

</tr></table>


<pre><span class="keyword">type</span> <a name="TYPEparse_error"></a><code class="type"></code>parse_error = <code class="type"><a href="Dtd.html#TYPEparse_error_msg">parse_error_msg</a> * <a href="Xml.html#TYPEerror_pos">Xml.error_pos</a></code> </pre>

<pre><span class="keyword">exception</span> <a name="EXCEPTIONParse_error"></a>Parse_error <span class="keyword">of</span> <code class="type"><a href="Dtd.html#TYPEparse_error">parse_error</a></code></pre>
<pre><span class="keyword">exception</span> <a name="EXCEPTIONCheck_error"></a>Check_error <span class="keyword">of</span> <code class="type"><a href="Dtd.html#TYPEcheck_error">check_error</a></code></pre>
<pre><span class="keyword">exception</span> <a name="EXCEPTIONProve_error"></a>Prove_error <span class="keyword">of</span> <code class="type"><a href="Dtd.html#TYPEprove_error">prove_error</a></code></pre>
<pre><span class="keyword">val</span> <a name="VALparse_error"></a>parse_error : <code class="type"><a href="Dtd.html#TYPEparse_error">parse_error</a> -> string</code></pre><pre><span class="keyword">val</span> <a name="VALcheck_error"></a>check_error : <code class="type"><a href="Dtd.html#TYPEcheck_error">check_error</a> -> string</code></pre><pre><span class="keyword">val</span> <a name="VALprove_error"></a>prove_error : <code class="type"><a href="Dtd.html#TYPEprove_error">prove_error</a> -> string</code></pre></body></html>